import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {AppUrl} from "../../app/app.general";
import {HttpClient} from "@angular/common/http";

/**
 * Generated class for the BusinessReportPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-business-report',
  templateUrl: 'business-report.html',
})
export class BusinessReportPage {

  private  curNotPaySum; //当日未支付笔数
  private  curTotalPrice; //当日总收入
  private  curPaySum; //当日已支付笔数
  private  curOrderSum; //当日订单总数
  private  orderSum; //订单总数
  private  totalPrice; //总收入
  private  paySum; //总支付笔数
  private  notPaySum; //总未支付笔数
  private  cancelSum; //取消笔数
  private  notConfirmSum; //商家未确认
  constructor(public navCtrl: NavController, public navParams: NavParams,private http:HttpClient) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad BusinessReportPage');
  }

  getData(){
    this.http.post(AppUrl.food.report, {restId: localStorage.getItem('restaurantid')}).subscribe(data => {
      let temp: any = data;
      if(temp.code == 200){

      this.curNotPaySum = temp.data[0].curNotPaySum; //当日未支付笔数
      this.curTotalPrice = temp.data[0].curTotalPrice; //当日总收入
      this.curPaySum =temp.data[0].curPaySum; //当日已支付笔数
      this.curOrderSum = temp.data[0].curOrderSum; //当日订单总数
      this.orderSum = temp.data[0].orderSum; //订单总数
      this.totalPrice = temp.data[0].totalPrice; //总收入
      this.paySum = temp.data[0].paySum; //总支付笔数
      this.notPaySum = temp.data[0].notPaySum; //总未支付笔数
      this.cancelSum = temp.data[0].cancelSum; //取消笔数
      this.notConfirmSum = temp.data[0].notConfirmSum;
      }
    });
  }
  ionViewWillEnter(){
   this.getData();
  }

}
